//package cn.com.itg.main;
//
//import com.alibaba.druid.pool.DruidDataSource;
//import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
//import com.github.lianjiatech.retrofit.spring.boot.config.GlobalTimeoutProperty;
//import com.github.lianjiatech.retrofit.spring.boot.config.RetrofitConfigBean;
//import com.github.lianjiatech.retrofit.spring.boot.config.RetrofitProperties;
//import com.github.lianjiatech.retrofit.spring.boot.core.RetrofitScan;
//import com.github.lianjiatech.retrofit.spring.boot.interceptor.ErrorDecoderInterceptor;
//import com.github.lianjiatech.retrofit.spring.boot.log.GlobalLogProperty;
//import com.github.lianjiatech.retrofit.spring.boot.log.LogLevel;
//import com.github.lianjiatech.retrofit.spring.boot.log.LogStrategy;
//import com.github.lianjiatech.retrofit.spring.boot.log.LoggingInterceptor;
//import com.github.lianjiatech.retrofit.spring.boot.retry.GlobalRetryProperty;
//import com.github.lianjiatech.retrofit.spring.boot.retry.RetryInterceptor;
//import com.github.lianjiatech.retrofit.spring.boot.retry.RetryRule;
//import org.mybatis.spring.mapper.MapperScannerConfigurer;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.PropertySource;
//import retrofit2.converter.jackson.JacksonConverterFactory;
//
//@PropertySource(value = {
//        "classpath:http-data-source.properties",
//        "classpath:jdbc.properties",
//        "classpath:log4j.properties"
//})
//@Configuration
////@ComponentScan({"cn.com.itg"})
////@RetrofitScan({"cn.com.itg"})
//public class SpringConfig {
//
//    @Bean
//    public DruidDataSource dataSource(
//            @Value("${jdbc.url}") String url,
//            @Value("${jdbc.username}") String username,
//            @Value("${jdbc.password}") String password,
//            @Value("${jdbc.driver}") String driver,
//            @Value("${jdbc.max-active}") Integer maxActive,
//            @Value("${jdbc.min-idle}") Integer minIdle
//    ) {
//
//        DruidDataSource druidDataSource = new DruidDataSource();
//        druidDataSource.setUrl(url);
//        druidDataSource.setUsername(username);
//        druidDataSource.setPassword(password);
//        druidDataSource.setDriverClassName(driver);
//        druidDataSource.setMaxActive(maxActive);
//        druidDataSource.setMinIdle(minIdle);
//        return druidDataSource;
//    }
//
//    @Bean
//    public MybatisSqlSessionFactoryBean sqlSessionFactory(DruidDataSource dataSource) {
//        MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
//        mybatisSqlSessionFactoryBean.setDataSource(dataSource);
//        return mybatisSqlSessionFactoryBean;
//    }
//
//    @Bean
//    public MapperScannerConfigurer mapperScannerConfigurer() {
//        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
//        mapperScannerConfigurer.setBasePackage("cn.com.itg.mapper");
//        return mapperScannerConfigurer;
//    }
//
//    @Bean
//    public RetrofitConfigBean retrofitConfigBean() {
//        RetrofitProperties retrofitProperties = new RetrofitProperties();
//        retrofitProperties.setGlobalConverterFactories(new Class[]{JacksonConverterFactory.class});
//        GlobalLogProperty globalLog = new GlobalLogProperty();
//        globalLog.setEnable(true);
//        globalLog.setLogLevel(LogLevel.INFO);
//        globalLog.setLogStrategy(LogStrategy.BASIC);
//        retrofitProperties.setGlobalLog(globalLog);
//        GlobalRetryProperty globalRetry = new GlobalRetryProperty();
//        globalRetry.setEnable(true);
//        globalRetry.setIntervalMs(100);
//        globalRetry.setMaxRetries(3);
//        globalRetry.setRetryRules(new RetryRule[]{RetryRule.RESPONSE_STATUS_NOT_2XX, RetryRule.OCCUR_EXCEPTION});
//        retrofitProperties.setGlobalRetry(globalRetry);
//        GlobalTimeoutProperty globalTimeout = new GlobalTimeoutProperty();
//        globalTimeout.setConnectTimeoutMs(5000);
//        globalTimeout.setReadTimeoutMs(5000);
//        globalTimeout.setWriteTimeoutMs(5000);
//        retrofitProperties.setGlobalTimeout(globalTimeout);
//        RetrofitConfigBean retrofitConfigBean = new RetrofitConfigBean(retrofitProperties);
//        retrofitConfigBean.setErrorDecoderInterceptor(new ErrorDecoderInterceptor());
//        retrofitConfigBean.setLoggingInterceptor(new LoggingInterceptor(retrofitProperties.getGlobalLog()));
//        retrofitConfigBean.setRetryInterceptor(new RetryInterceptor(retrofitProperties.getGlobalRetry()));
//        return new RetrofitConfigBean(retrofitProperties);
//    }
//
////    @Bean
////    public HttpDataSource httpDataSource(
////            @Value("${http.datasource.max-idle-connections}") Integer maxIdleConnections,
////            @Value("${http.datasource.keep-alive-duration-ns}") Integer keepAliveDurationNs,
////            @Value("${http.datasource.conn-time-out}") Integer connTimeOut,
////            @Value("${http.datasource.read-time-out}") Integer readTimeOut,
////            @Value("${http.datasource.write-time-out}") Integer writeTimeOut
////    ) {
////        HttpDataSource httpDataSource = new HttpDataSource();
////        httpDataSource.setMaxIdleConnections(maxIdleConnections);
////        httpDataSource.setKeepAliveDurationNs(keepAliveDurationNs);
////        httpDataSource.setConnTimeOut(connTimeOut);
////        httpDataSource.setReadTimeOut(readTimeOut);
////        httpDataSource.setWriteTimeOut(writeTimeOut);
////        return httpDataSource;
////    }
////
////    @Bean
////    public HttpApiScannerConfigurer httpApiScannerConfigurer() {
////        HttpApiScannerConfigurer httpApiScannerConfigurer = new HttpApiScannerConfigurer();
////        httpApiScannerConfigurer.setBasePackage("cn.com.itg.api");
////        return httpApiScannerConfigurer;
////    }
//}
